package work6;

import javax.swing.text.Position;
import java.util.Scanner;

public class StringExample {
    public static void main(String[] args) {
        String s1 = new String("you are a student"),
                s2 = new String("how are you");
        if (s1.equals(s2)){
            System.out.println("s1与s2相同");
        }
             else{
            System.out.println("s1与s2不相同");
        }
        String s3 = new String("22030219851022024");
            if (s3.startsWith("220303")){
                System.out.println("吉林省身份证");
            }else {
                System.out.println("这不是吉林省身份证");
            }
            String s4 = new String("你"),
                    s5 = new String("我");
            if(s4.compareTo(s5)>0)
                System.out.println("按字典序，s4大于s5");  //按字典符，S4大于S5的表达式
                else
                    System.out.println("按字典序,s4小于s5");
            int position = 0;
            String path = "C\\java\\jsp\\A.java";
            position = path.lastIndexOf("\\"); //获取path中最后出现目录分隔符号的位置
        System.out.println("C\\java\\jsp\\A.java最后出现的位置："+position);
        String fileName = path.substring(position+1);  //获取path中"A.java"子字符串
        System.out.println("C\\java\\jsp\\A.java中含有的文件名："+fileName);

        String s6 = new String("100");
        String s7 = new String("123.678");
        int n1 = Integer.parseInt(s6); //将s7转化成int数据
        double n2 = Double.parseDouble(s7); //将s7转化成double数据
        double n = n1+n2;
        System.out.println(n);

        String s8 = new String("ABCDEF");
        char a[] = s8.toCharArray(); //将s8存放到数组A中
        for (int i = a.length-1; i>=0; i--)
            System.out.printf("%3c",a[i]);
        System.out.println("\n0501刘冰");
    }
}
